refactor(vr): prefer globals::game::isVR#113
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Refactor to prefer cached globals::game::isVR over REL::Module::IsVR()
Refactor VR runtime checks to prefer cached Jun 6, 2026
globals::game::isVR
Aligns the inline comment spacing and macro line-continuation backslashes added by the globals::game::isVR refactor so the pre-commit.ci clang-format hook passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
globals::game::isVR|
No actionable suggestions for changed features. |
There was a problem hiding this comment.
Pull request overview
This PR refactors VR runtime branching across the rendering/plugin codebase to prefer the cached globals::game::isVR flag instead of repeated REL::Module::IsVR() checks, while preserving direct module checks in early-init / static-init contexts where globals::game::isVR may not be initialized yet.
Changes:
- Replaced many runtime
REL::Module::IsVR()checks withglobals::game::isVRacross hooks, rendering paths, shader compilation/defines, UI helpers, and feature code. - Constrained remaining direct module checks to known init-order-sensitive sites (plugin early load, header/static initialization, and the cache population site) and annotated those exceptions.
- Standardized VR define insertion and VR/flat branching to route through the cached global where timing is safe.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/XSEPlugin.cpp | Keeps direct VR check for pre-ReInit gating, uses cached globals::game::isVR after globals::ReInit() for runtime DLL gating. |
| src/Utils/UI.cpp | Routes VR-specific input/display logic through globals::game::isVR. |
| src/Utils/Game.h | Documents why macros retain direct module VR checks (macro may be used pre-ReInit). |
| src/Utils/Game.cpp | Uses cached VR flag for camera/eye and TAA runtime branching. |
| src/Utils/D3D.h | Switches VR-aware render target count helpers to cached VR flag. |
| src/Utils/D3D.cpp | Uses cached VR flag when adding shader compile macros. |
| src/TruePBR.cpp | Uses cached VR flag for VR-vs-flat allocation sizing. |
| src/ShaderCache.h | Annotates and retains direct module check for static initialization safety. |
| src/ShaderCache.cpp | Uses cached VR flag for SIE signature/define logic and shader compile defines. |
| src/Menu/HomePageRenderer.cpp | Uses cached VR flag to suppress first-time setup in VR. |
| src/Menu.h | Annotates and retains direct module check for ctor-time default initialization. |
| src/Hooks.cpp | Uses cached VR flag for install-time gating and VR/flat patch selection. |
| src/Globals.h | Annotates why header helpers keep direct module checks to avoid init-order coupling. |
| src/Globals.cpp | Keeps module check as the source-of-truth to populate globals::game::isVR; uses cached flag downstream. |
| src/Features/VRStereoOptimizations.cpp | Uses cached VR flag to early-out VR-only resource/setup paths. |
| src/Features/VR/StereoBlend.cpp | Uses cached VR flag for VR-only stereo blend execution gating. |
| src/Features/VR.h | Uses cached VR flag for VR feature readiness predicate. |
| src/Features/Upscaling/PerfMode/MenuBridge.cpp | Uses cached VR flag for VR-only RT thunk installation. |
| src/Features/Upscaling/DX12SwapChain.cpp | Uses cached VR flag for VR-specific swap chain behavior. |
| src/Features/Skylighting.cpp | Uses cached VR flag for VR-specific hook installation. |
| src/Features/ScreenSpaceGI.h | Uses cached VR flag for VR warning text; retains module checks for ctor defaults. |
| src/Features/ScreenSpaceGI.cpp | Uses cached VR flag for VR-only shader variants, stereo iteration counts, and stereo sync pass gating. |
| src/Features/ScreenshotFeature.cpp | Uses cached VR flag for VR-only default preset seeding. |
| src/Features/RemoteControl/DevBenchBridge.cpp | Uses cached VR flag for VR compatibility enforcement and telemetry payload. |
| src/Features/LightLimitFix/ShadowCasterManager.cpp | Uses cached VR flag for VR/flat calling conventions and runtime data access branching. |
| src/Features/LightLimitFix.h | Annotates and retains direct module check for ctor-time default eye count. |
| src/Features/LightLimitFix.cpp | Uses cached VR flag for VR-specific sizing/defines and render-size branching. |
| src/Features/GrassCollision.cpp | Uses cached VR flag for VR per-frame buffer selection. |
| src/FeatureIssues.cpp | Uses cached VR flag for VR feature INI gating. |
| src/Feature.cpp | Uses cached VR flag to choose the VR-vs-flat feature list. |
| src/Deferred.h | Uses cached VR flag for VR-vs-flat hook installation decisions. |
| src/Deferred.cpp | Uses cached VR flag for VR buffer binding and shader define selection. |
alandtse
approved these changes
Jun 7, 2026
|
✅ A pre-release build is available for this PR: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This refactor applies the VR-divergence guideline by replacing direct
REL::Module::IsVR()runtime checks with the cachedglobals::game::isVRwhere call timing is safe. Remaining raw module checks are intentionally limited to init/early-init and header initialization contexts.Scope: timing-safe runtime callsites
globals::game::isVRacross major runtime paths insrc/(deferred rendering, hooks, shader cache runtime logic, UI/game utils, feature runtime code including LLF/SSGI/VR/upscaling).Intentional raw-check exceptions
REL::Module::IsVR()at the cache population site inGlobals.cpp.XSEPlugin.cpp) whereglobals::game::isVRis not yet initialized.Globals.h,ShaderCache.h,Utils/Game.h,ScreenSpaceGI.h,LightLimitFix.h,Menu.h) where initialization order/timing can precedeReInit.Net effect
globals::game::isVR, with raw calls constrained to legitimate init-order exceptions.